import { combineReducers } from 'redux';
import { jtData, mdData } from './wxCommonReducer';
import {
    TESTSMARTDR, WXGETSUBPRODUCT, ZHCTPRODUCTCONF, WXZHCTGETLIST, WSTIMIESELCTED
} from '../actions/smartDr.js'

const testnum = (state = 0, action) => {
    if (action.type === TESTSMARTDR) {
        return state + 1
    }
    return state
}

const wxSubProducts = (state = {}, action) => {
    if (action.data && action.type === WXGETSUBPRODUCT) {
        state = action.data.data
    }
    return state
}

const wxzhctSubProduct = (state = [], action) => {
    if (action.type === ZHCTPRODUCTCONF) {
        state = action.data
    }
    return state
}

const wxzhctListData = (state = [], action) => {
    if (action.data && action.type === WXZHCTGETLIST) {
        state = action.data.data
    }
    return state
}

const wxTimeSelectData = (state = [], action) =>{
    if(action.type == WSTIMIESELCTED){
        if(action.data.length){            
            state.push(action.data);
            return state;
        }
        return state;
    }
    return state;
}
const wxSmartdrs = combineReducers({
    wxSubProducts,
    wxzhctSubProduct,
    jtData,
    mdData,
    wxzhctListData,
    wxTimeSelectData
});
export default wxSmartdrs;
